package com.itheima.dao;

import com.itheima.domain.Dir;
import org.apache.ibatis.annotations.*;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

@Mapper
public interface DirDao {



    @Select("select * from dir where id=#{id} ")
    List<Dir> findALLById(int id);

    @Select("select * from dir where id=#{id} and dtype='is' ")
    List<Dir> findShare(int id);

    @Insert("insert into dir(id,ddate,dname,dtype,dsize,dpath) values(#{id},#{ddate},#{dname},'no',#{dsize},#{dpath})")
    void AddDir(@Param("id") Integer id, @Param("ddate") String ddate, @Param("dname") String dname, @Param("dtype") String dtype, @Param("dsize") Double dsize, @Param("dpath") String dpath);


    @Select("select * from dir where id=#{id}")
    List<Dir> findAllByUid(Integer id);

    @Update("update dir set dtype='no' where did =#{did} ")
    void offShare(Integer did);
    @Update("update dir set dtype='is' where did =#{did} ")
    void onShare(Integer did);

    @Select("Select *,username,phone from dir,user  where dtype='is' and dir.id=user.id")
    List<Dir> findAllShare();


    @Delete("delete from dir where did=#{did}")
    void delDir(Integer did);



}